<template>
  <div class="commission">

    <dt-search ref="search" :labelWidth="100" @reset="onReset">
      <Button type="primary" @click="exportExcelFun">导出记录</Button>
    </dt-search>
    <dt-grid ref="table" :columns="columns" page :onFetch='onFetch' />
  </div>
</template>

<script>
  import columnOpt from './opt/column.js'
  import searchOpt from './opt/search.js'
  import caseMgr from '@/biz/crimeSceneList'
  import toolApi from '@/biz/base/tool'

  export default {
    data() {
      return {
        columns: [],
        status: '0',
        labelWidth: 100,
        filterParams: {},
        formValidate: {
          time: [],
          // buildingId: '',
          inOrgIds: [],
          // inOrgLevel: [],
          oaIds: [],
          outOrgIds: [],
          // outOrgLevel: [],
          // operationDateStart: '',
          // operationDateEnd: '',
        },
      }
    },
    mounted() {
      this.columns = new columnOpt(this).options()
      this.$refs.table.init(this)
      this.$refs.search.init(this.$refs.table, new searchOpt(this).options(), this
        .formValidate)
      this.$refs.table.fetch()
    },
    methods: {
      exportExcelFun(val) {

        let params = Object.assign(this.filterParams)
        params.page = 1
        params.current = 1

        toolApi.downloadCenter('/dt-user/org/exportBuildingLog', params)
      },
      onReset() {
        // this.columns = new columnOpt(this).options()
        // this.$refs.table.init(this)
        this.$refs.search.init(this.$refs.table, new searchOpt(this).options(), this
          .formValidate)
        // this.$refs.table.fetch()
      },

      onFetch(data) {
        let params = data
        params.inOrgLevel = 3
        params.outOrgLevel = 3
        params.operationDateStart = data.time[0]
        params.operationDateEnd = data.time[1]

        // let params = {
        //   buildingId: data.buildingId,
        //   inOrgIds: data.inOrgIds,
        //   inOrgLevel: 3,
        //   oaIds: data.oaIds,
        //   operationDateStart: data.time[0],
        //   operationDateEnd: data.time[1],
        //   outOrgIds: data.outOrgIds,
        //   outOrgLevel: 3,
        //   ...data
        // }
        this.filterParams = { ...params }
        return caseMgr.getBuildingLog(params)

      },
    },
  }
</script>

<style lang="scss" scoped>
  .commission {
    padding: 20px;

    .title {
      margin-bottom: 20px;
      font-size: 20px;
    }

    .info {
      line-height: 2;
      display: flex;
      flex-direction: row;
      flex-wrap: wrap;

      p {
        width: 40%;

        span {
          display: inline-block;
          width: 100px;
          margin-right: 10px;
          text-align: right;
        }

        em {
          font-style: normal;
        }
      }
    }
  }

  .qie {
    // margin-top: 20px;
  }
</style>